module.exports = function(obj,JSONMeth){
	function clon(p){
	if(!p || typeof p !== "object") return p;
    if(JSONMeth && JSON){
      return JSON.parse(JSON.stringify(p));
    }else{
			var o = {};
			if(p.constructor === Array){
				o = [];
				for(var i = 0; i < p.length; i ++) o[i] = typeof p[i] !== "object" ? p[i] : (!p[i] ? p[i] : clon(p[i]));
			}else{
				for(var key in p) o[key] = typeof p[key] !== "object" ? p[key] : (!p[key] ? p[key] : clon(p[key]));
			}
      return o;
    }
	}
	return clon(obj);
}